'''
Created on Apr 16, 2012
TC ID: Ecom_5015
Desc: Kiem thu chuc nang xoa mot User
@author: lavang
'''
import unittest
from Functions.globalFunc import readData, preCondition, endCondition
from Functions.loginPageFunc import login
from Functions.usersFunc import clickOnUsers, deleteUser,\
    isUserCreatedSuccessfully
from HTMLTestRunner import HTMLTestRunner
import time

username = readData("username")
password = readData("password")
tm_user=readData("users")
class Ecom_5015(unittest.TestCase):


    def setUp(self):
        preCondition(self)
        
    def test_Ecom_5015(self):
        print "Buoc 1: Dang nhap vao website"
        login(self,username, password)
        
        print "Buoc 2: Click vao Users"
        clickOnUsers(self)
        
        print "Buoc 3: Xoa mot User da chon"
        deleteUser(self,tm_user)
        
        print "Buoc 5: Kiem tra loai bai hoc da duoc xoa hay chua?"
        self.assertFalse(isUserCreatedSuccessfully(self,tm_user), "Failed: User chua duoc xoa thanh cong")
        print "Passed: User da duoc xoa thanh cong"
        
    def tearDown(self):
        endCondition(self)
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5015)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang xoa mot User'
                    )
    runner.run(suite)